<template>
  <div o-Container>
    <o-list v-bind:source="list.contract" v-bind="{ exported: output }">
      <template slot="config" slot-scope="scope">
        <div class="img_box">
          <img
            @click="showLookDiaolog(scope)"
            src="/static/skin/default/MCS/AIGC/Inventory/images/chakan.png"
            alt=""
          />
        </div>
        <div class="img_box">
          <img
            @click="del({ id: scope.data.row.ID, IsAudit: 0 })"
            src="/static/skin/default/MCS/AIGC/Inventory/images/shanchu.png"
            alt=""
          />
        </div>
      </template>
    </o-list>
    <EvaluateMsg
      ref="EvaluateMsg"
      :messageList="messageList"
      @husbandEvent="alterTheState"
    ></EvaluateMsg>
  </div>
</template>

<script>
import EvaluateMsg from "../Components/EvaluateMsg.vue";
export default {
  components: {
    EvaluateMsg
  },
  name:
    "mms_platform_company_list" /* 这个name暂时不知道用啥用，根据官方文档说的是方便排错的 */,
  data() {
    return {
      octopus: this.$parent.octopus,
      list: {
        contract: {
          data: {
            id: 1257, // 菜单表的八爪鱼ID
            cellData: [
              { name: "IsAudit", width: 50 }, // 是否展示
              { name: "IsException", width: 50 }, // 是否异常
              { name: "Content", width: 400 }, // 评论内容
              { name: "PhotoPath", width: 350 }, // 评论图片
              { name: "EquityName", width: 350 }, // 权益名称
              { name: "UserScore", width: 50 }, // 用户评分
              { name: "productName", width: 350 }, // 产品名
              { name: "FlagList", width: 50 }, // 产品类型
              { name: "CreateUserID" }, // 评论人
              { name: "Code", width: 200 }, // 订单code
              { name: "ID", show: false }, // ID

              { name: "CompanyID", show: false }, // 公司ID
              { name: "CreateTime", show: false }, // 创建时间
              { name: "EquityID", show: false }, // 权益ID
              { name: "ParentID", show: false }, // 评论父ID
              { name: "PurchaseID", show: false }, // 订单ID
              { name: "ReplyUserID", show: false }, // 被回复用户ID
              { name: "ServiceScore", show: false }, // 服务评分
              { name: "TypeID", show: false } // TypeID
            ],
            paramData: {}
          },
          configWidth: 80,
          showNumber: true
        }
      },
      messageList: {},
      messageListAdd: {}
    };
  },
  created() {
    this.init();
  },
  methods: {
    init() {
      this.list.contract.data.paramData.CompanyID =
        this.octopus.passport.authorization.company == 1
          ? "NULL"
          : this.octopus.passport.authorization.company;
    },
    showLookDiaolog(row) {
      this.messageList = row.data.row;
      this.$refs.EvaluateMsg.drawerOp();
    },
    alterTheState(data) {
      let o = this;
      this.octopus.request.api.post(
        "/Octopus/Engine/Item",
        {
          id: 1214, // 菜单表的八爪鱼ID
          type: "UPDATE",
          value: data.id,
          cellData: [
            { name: "IsAudit", defaultValue: data.IsAudit }, // IsAudit
            { name: "IsException" } // IsException
          ]
        },
        function(data) {
          if (data.status.code == 200) {
            o.list.contract.control.load();
          } else {
            o.octopus.tips.error(data);
          }
        }
      );
    },
    output: function(data) {
      this.octopus.tips.success("下载完成。");
    },
    search: function(cell) {},
    save: function(data) {
      // 保存
      this.octopus.tips.success(data);
      // 刷新list
      this.list.contract.control.load();
      this.back();
    },
    back: function() {
      this.panel.visible = false;
    },
    del: function(row) {
      let o = this;
      // alert("del key: " + JSON.stringify(row));
      this.$confirm("此操作将永久删除该项, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.octopus.request.api.post(
            "/Octopus/Engine/Item",
            {
              id: 1214, // 菜单表的八爪鱼ID
              type: "UPDATE",
              value: row.id,
              cellData: [{ name: "IsDelete", defaultValue: 1 }]
            },
            // 处理回调事件，通过分析data.status.code的状态来实现。
            function(data) {
              if (data.status.code === 200) {
                o.list.contract.control.load();
              } else {
                o.octopus.tips.error(data);
              }
            }
          );
          this.$message({
            type: "success",
            message: "删除成功!"
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    }
  },
  props: ["oData"]
};
</script>
<style scoped>
.el-message-box {
  background-color: #fff !important;
}

.img_box {
  display: flex;
  justify-content: space-between;
  width: 100%;
}

.img_box img {
  width: 25px;
  cursor: pointer;
}
</style>
